import re
def validator(func):
    def inner(prompt):
        while True:
            try:
                input_str = input(prompt).strip()
                if not input_str:
                    raise ValueError("输入不能为空")
                if not re.match(r'^-?\d+(\.\d+)?$', input_str):
                    raise ValueError("输入格式不正确")
                return input_str
            except ValueError as e:
                print(f"{e}，请重新输入: ")
    return inner

@validator
def myInput(prompt):
    return prompt

a = myInput("请输入a: ")
b = myInput("请输入b: ")
c = float(a) + float(b)
print(c)
